package com.lej.login.http

import com.google.gson.JsonElement
import com.google.gson.JsonObject
import com.lej.core.base.app
import com.lej.core.utils.extention.versionCode
import com.lej.dataservice.club.bean.login.LoginRes
import com.lej.dataservice.club.bean.login.WxLoginRes
import com.lej.dataservice.club.bean.register.RegisterUserInfo
import com.lej.dataservice.club.http.BaseResponse
import com.lej.dataservice.club.http.RetrofitClient
import okhttp3.RequestBody
import retrofit2.http.*

val loginApiService: LoginApiService =
    RetrofitClient.getInstance().create(LoginApiService::class.java)

interface LoginApiService {


    /**获取手机号验证码*/
    @Headers("Content-Type: application/json")
    @POST("/trove/login/getVerifyCode")
    suspend fun getAutoCode(@Body array: RequestBody): BaseResponse<JsonObject>

    /**获取绑定手机号验证码*/
    @Headers("Content-Type: application/json")
    @POST("/trove/users/savePhoneGetVerifyCode")
    suspend fun getBindAutoCode(@Body array: RequestBody): BaseResponse<JsonObject>
    /**登录接口*/
    @Headers("Content-Type: application/json")
    @POST("/trove/login/phoneLogin")
    suspend fun autoLogin(@Body body: RequestBody): BaseResponse<LoginRes>

    /**
     * 修改用户信息
     */
    @Headers("Content-Type: application/json")
    @POST("/trove/users/update")
    suspend fun updateInfo(@Body body: RequestBody): BaseResponse<JsonObject>

    /**
     * 根据拥有的数字藏品判断用户属性
     */
    @Headers("Content-Type: application/json")
    @GET("/trove/nftBackpack/usersAttr")
    suspend fun userAttr(): BaseResponse<JsonObject>

    /**完善资料*/
    @Headers("Content-Type: application/json")
    @POST("/auth/register")
    suspend fun pushInfo(@Body body: RequestBody): BaseResponse<LoginRes>

    //推送绑定 [maker] 厂商
    @FormUrlEncoded
    @POST("api/registercid")
    suspend fun bindingCid(
        @Field("cid") uuid: String?,
        @Field("type") type: String? = "1",
        @Field("version") version: String? = app.versionCode.toString(),
        @Field("maker") maker: String?
    ): BaseResponse<JsonElement>

    //用户完善的信息
    @GET("api/memberprofile")
    suspend fun memberprofile(): BaseResponse<RegisterUserInfo>

    /**
     * 配置接口。守护灵对话信息,登录页视频
     */
    @Headers("Content-Type: application/json")
    @GET("/trove/client/config_data")
    suspend fun configSever(@Query("tags[]") list: List<String>,
                            @Query("version") version: String): BaseResponse<JsonObject>

    /**微信登录*/
    @Headers("Content-Type: application/json")
    @POST("/trove/login/wechatLogin")
    suspend fun wxLogin(@Body body: RequestBody): BaseResponse<WxLoginRes>

    /**手机号仅登录（不注册）*/
    @Headers("Content-Type: application/json")
    @POST("/trove/login/phoneOnlyLogin")
    suspend fun phoneOnlyLogin(@Body body: RequestBody): BaseResponse<WxLoginRes>

    /**绑定手机号*/
    @Headers("Content-Type: application/json")
    @POST("/trove/users/bindPhone")
    suspend fun bindPhone(@Body body: RequestBody): BaseResponse<WxLoginRes>

}